What's the Ruby equivalent of Python's output[:-1]?

Posted by Thierry Lam on Stack Overflow See other posts from Stack Overflow or by Thierry Lam
Published on 2010-03-20T21:34:24Z Indexed on 2010/03/20 21:41 UTC
Read the original article Hit count: 407

Filed under:
|

In Python, if I want to get the first n characters of a string minus the last character, I do:

output = 'stackoverflow'
print output[:-1]

I can do the above in Ruby with:

output = 'stackoverflow'
output.reverse[1..output.length]

Is there another way to perform this action in Ruby?

© Stack Overflow or respective owner

Related posts about python

Related posts about ruby